<template>
  <div class="process-config-tabs">
    <el-tabs v-model="activeName" type="border-card">
      <el-tab-pane label="基础设置" name="basic">
        <basic-tab ref="basicTab" />
      </el-tab-pane>
      <el-tab-pane label="开户" name="openAccount">
        <openAccountTab ref="openAccountTab" />
      </el-tab-pane>
      <el-tab-pane label="下单" name="order">
        <order-tab ref="orderTab" />
      </el-tab-pane>
      <el-tab-pane label="库存" name="store">
        <store-tab ref="storeTab" />
      </el-tab-pane>
      <el-tab-pane label="配送" name="distribution">
        <distribution-tab ref="distributionTab" />
      </el-tab-pane>
      <el-tab-pane label="结算" name="settlement">
        <settlement-tab ref="settlementTab" />
      </el-tab-pane>
      <el-tab-pane label="微信配置" name="wechat">
        <wechat-tab ref="wechatTab" />
      </el-tab-pane>
      <el-tab-pane label="支付方式配置" name="payway">
        <payway-tab ref="paywayTab" />
      </el-tab-pane>
      <el-tab-pane label="预约时间" name="appointmentTime">
        <appointment-time ref="appointmentTime" />
      </el-tab-pane>
      <el-tab-pane label="精准时间配置" name="preciseTime">
        <preciseTime ref="preciseTime" />
      </el-tab-pane>
    </el-tabs>
    <div class="btn">
      <el-button v-permission="1" type="primary" :loading="$loadingPlugin.save" @click="save">保存配置</el-button>
    </div>
  </div>
</template>

<script>
  import { appointTimeSettingDaySave, appointTimeSettingSave, querySaveProcessConfig } from '@/api'
  import moment from 'dayjs'
  import BasicTab from './BasicTab'
  import openAccountTab from './openAccount'
  import OrderTab from './OrderTab'
  import StoreTab from './StoreTab'
  import DistributionTab from './DistributionTab'
  import SettlementTab from './SettlementTab'
  import WechatTab from './WechatTab'
  import PaywayTab from './PaywayTab'
  import appointmentTime from './appointmentTime'
  import preciseTime from './preciseTime'
  import { keepDotLength } from '@/utils/math'
  import store from '@/store'
  import dayjs from 'dayjs'

  export default {
    name: 'processConfig',
    components: {
      BasicTab, openAccountTab, OrderTab, StoreTab, DistributionTab, SettlementTab, WechatTab, PaywayTab, appointmentTime,
      preciseTime
    },
    data() {
      return {
        activeName: 'basic'
      }
    },
    async created() {
      await store.dispatch('user/getCorpSettingData')
    },
    methods: {
      handleVal(arr) {
        let k = 0
        if (arr.length > 0) {
          arr.forEach(item => {
            k |= Number(item)
          })
        }
        return k
      },
      async save() {
        const params = {
          pbxURL: this.$refs.basicTab.query.pbxURL,
          monthlyDayNum: this.$refs.orderTab.query.monthlyDayNum,
          buyMax: this.$refs.orderTab.query.buyMax || 999,
          exchangeBuyMax: this.$refs.orderTab.query.exchangeBuyMax || 999,
          limitSpare: this.$refs.paywayTab.query.limitSpare || 0,
          wxLimitTime: this.$refs.wechatTab.time ? moment(this.$refs.wechatTab.time[0]).format('HH:mm') + '-' + moment(this.$refs.wechatTab.time[1]).format('HH:mm') : '',
          wxUpMin: this.$refs.wechatTab.query.wxUpMin << 1,
          sp1: 0,
          sp2: 0,
          registerTips: this.$refs.orderTab.query.registerTips,
          onlineAudit: this.$refs.basicTab.query.onlineAudit,
          offlineAudit: this.$refs.basicTab.query.offlineAudit,
          depAuditChannel: this.handleVal(this.$refs.basicTab.query.depAuditChannel),
          depReceiptChannel: this.handleVal(this.$refs.orderTab.query.depReceiptChannel),
          diffDistance: this.$refs.distributionTab.query.diffDistance,
          // userOrderDays: this.$refs.distributionTab.query.days - 1,
          scanLimitTime: this.$refs.distributionTab.query.scanLimitTime,
          // goodsCountFree: this.$refs.openAccountTab.goodsCountFree || 0,
          orderSignUpdateFee: this.$refs.distributionTab.query.orderSignUpdateFee
        }
        if (params.limitSpare > 480) {
          this.$message.warning('微信下单未支付限时作废时间不可超过最大值480')
          return
        }
        params.fee1 = (keepDotLength((this.$refs.basicTab.query.fee1 || 0), 2) * 100).toFixed(0) // 上楼基础费
        if (this.$refs.orderTab.query.ck_007_sys_setting_1_1) params.sp1 |= 1 << 1
        if (this.$refs.orderTab.query.ck_007_sys_setting_1_2) params.sp1 |= 1 << 2
        if (this.$refs.orderTab.query.ck_007_sys_setting_1_3) params.sp1 |= 1 << 3
        if (this.$refs.orderTab.query.ck_007_sys_setting_1_4) params.sp1 |= 1 << 4
        if (this.$refs.orderTab.query.ck_007_sys_setting_1_6) params.sp1 |= 1 << 6
        if (this.$refs.paywayTab.query.ck_007_sys_setting_1_7) params.sp1 |= 1 << 7
        if (this.$refs.paywayTab.query.ck_007_sys_setting_1_8) params.sp1 |= 1 << 8
        if (this.$refs.orderTab.query.ck_007_sys_setting_1_9) params.sp1 |= 1 << 9
        if (this.$refs.orderTab.query.ck_007_sys_setting_1_10) params.sp1 |= 1 << 10
        if (this.$refs.orderTab.query.ck_007_sys_setting_1_11) params.sp1 |= 1 << 11
        if (this.$refs.orderTab.query.le > 0) params.sp1 |= (((this.$refs.orderTab.query.le & 0x07) - 1) << 12)
        if (this.$refs.openAccountTab.query.ck_007_sys_setting_1_15) params.sp1 |= 1 << 15
        if (this.$refs.orderTab.query.ck_007_sys_setting_1_16) params.sp1 |= 1 << 16
        if (this.$refs.orderTab.query.ck_007_sys_setting_1_17) params.sp1 |= 1 << 17
        if (this.$refs.basicTab.query.maxFloor > 0) {
          params.sp1 |= ((this.$refs.basicTab.query.maxFloor & 0xF) << 18)
        }
        if (this.$refs.basicTab.query.ck_007_sys_setting_1_22) params.sp1 |= 1 << 22
        if (this.$refs.orderTab.query.ck_007_sys_setting_1_23) params.sp1 |= 1 << 23
        if (this.$refs.orderTab.query.ck_007_sys_setting_1_24) params.sp1 |= 1 << 24
        if (this.$refs.basicTab.query.ck_007_sys_setting_1_25) params.sp1 |= 1 << 25
        if (this.$refs.orderTab.query.ck_007_sys_setting_1_27) params.sp1 |= 1 << 27
        if (this.$refs.basicTab.query.ck_007_sys_setting_1_28) params.sp1 |= 1 << 28
        if (this.$refs.orderTab.query.ck_007_sys_setting_1_29) params.sp1 |= 1 << 29
        if (this.$refs.openAccountTab.query.ck_007_sys_setting_1_30) params.sp1 |= 1 << 30
        params.wxUpMin |= 1

        if (this.$refs.distributionTab.query.ck_007_sys_setting_2_0) params.sp2 |= 1
        if (this.$refs.distributionTab.query.ck_007_sys_setting_2_2) params.sp2 |= 1 << 2
        if (this.$refs.distributionTab.query.ck_007_sys_setting_2_3) params.sp2 |= 1 << 3

        // // 天数 int 值
        // const days = this.$refs.distributionTab.query.days
        // if (days > 0) {
        //   if (days > 7) {
        //     params.sp2 |= (((7 & 0x07) - 1) << 4)
        //   } else {
        //     params.sp2 |= (((days & 0x07) - 1) << 4)
        //   }
        //   params.billMaxDate = days
        // }
        if (this.$refs.paywayTab.query.ck_007_sys_setting_2_7) params.sp2 |= 1 << 7
        if (this.$refs.distributionTab.query.ck_007_sys_setting_2_8) params.sp2 |= 1 << 8
        if (this.$refs.distributionTab.query.ck_007_sys_setting_2_9) params.sp2 |= 1 << 9
        if (this.$refs.distributionTab.query.ck_007_sys_setting_2_10) params.sp2 |= 1 << 10
        if (this.$refs.distributionTab.query.ck_007_sys_setting_2_11) params.sp2 |= 1 << 11
        if (this.$refs.storeTab.query.ck_007_sys_setting_2_12) params.sp2 |= 1 << 12
        if (this.$refs.settlementTab.query.ck_007_sys_setting_2_13) params.sp2 |= 1 << 13
        if (this.$refs.distributionTab.query.ck_007_sys_setting_2_14) params.sp2 |= 1 << 14
        if (this.$refs.distributionTab.query.ck_007_sys_setting_2_15) params.sp2 |= 1 << 15
        if (this.$refs.basicTab.query.ck_007_sys_setting_2_16) params.sp2 |= 1 << 16
        if (this.$refs.distributionTab.query.ck_007_sys_setting_2_17) params.sp2 |= 1 << 17
        if (this.$refs.settlementTab.query.ck_007_sys_setting_2_18) params.sp2 |= 1 << 18
        if (this.$refs.settlementTab.query.ck_007_sys_setting_2_19) params.sp2 |= 1 << 19
        if (this.$refs.settlementTab.query.ck_007_sys_setting_2_20) params.sp2 |= 1 << 20
        if (this.$refs.paywayTab.query.ck_007_sys_setting_2_21) params.sp2 |= 1 << 21
        if (this.$refs.basicTab.query.ck_007_sys_setting_2_24) params.sp2 |= 1 << 24
        if (this.$refs.distributionTab.query.ck_007_sys_setting_2_25) params.sp2 |= 1 << 25
        if (this.$refs.basicTab.query.ck_007_sys_setting_2_26) params.sp2 |= 1 << 26
        if (this.$refs.orderTab.query.ck_007_sys_setting_2_27) params.sp2 |= 1 << 27
        if (this.$refs.orderTab.query.ck_007_sys_setting_2_28) params.sp2 |= 1 << 28
        if (this.$refs.settlementTab.query.ck_007_sys_setting_2_30) params.sp2 |= 1 << 30
        if (this.$refs.settlementTab.query.ck_007_sys_setting_2_31) params.sp2 |= 1 << 31
        if (this.$refs.settlementTab.query.ck_007_sys_setting_sp6_4) params.sp6 |= 1 << 4
        if (this.$refs.settlementTab.query.ck_007_sys_setting_sp6_13) params.sp6 |= 1 << 13
        if (this.$refs.settlementTab.query.ck_007_sys_setting_sp6_14) params.sp6 |= 1 << 14
        if (this.$refs.storeTab.query.radio_sp6_5) params.sp6 |= 1 << 5
        if (this.$refs.storeTab.query.radio_sp6_6) params.sp6 |= 1 << 6
        if (this.$refs.storeTab.query.ck_007_sys_setting_6_27) params.sp6 |= 1 << 27

        if (this.$refs.distributionTab.query.ck_007_sys_setting_3_0) params.sp3 |= 1
        if (this.$refs.paywayTab.query.ck_007_sys_setting_3_1) params.sp3 |= 1 << 1
        if (this.$refs.orderTab.query.ck_007_sys_setting_3_2) params.sp3 |= 1 << 2
        if (this.$refs.storeTab.query.radio === '1') params.sp3 |= 1 << 3
        if (this.$refs.storeTab.query.radio2 === '1') params.sp6 |= 1 << 5
        if (this.$refs.storeTab.query.radio3 === '1') params.sp6 |= 1 << 6
        if (this.$refs.storeTab.query.radio3 === '2') params.sp6 |= 1 << 7
        if (this.$refs.storeTab.query.radio3 === '3') params.sp6 |= 1 << 8
        if (this.$refs.orderTab.query.ck_007_sys_setting_3_5) params.sp3 |= 1 << 5
        if (this.$refs.storeTab.query.ck_007_sys_setting_3_6) params.sp3 |= 1 << 6
        if (this.$refs.storeTab.query.ck_007_sys_setting_3_7) params.sp3 |= 1 << 7
        if (this.$refs.basicTab.query.ck_007_sys_setting_3_8) params.sp3 |= 1 << 8
        if (this.$refs.orderTab.query.ck_007_sys_setting_3_9) params.sp3 |= 1 << 9
        if (this.$refs.basicTab.query.ck_007_sys_setting_3_10) params.sp3 |= 1 << 10
        if (this.$refs.basicTab.query.ck_007_sys_setting_3_14) params.sp3 |= 1 << 14
        if (this.$refs.orderTab.query.ck_007_sys_setting_3_15) params.sp3 |= 1 << 15
        if (this.$refs.paywayTab.query.ck_007_sys_setting_3_16) params.sp3 |= 1 << 16
        if (this.$refs.paywayTab.query.ck_007_sys_setting_3_17) params.sp3 |= 1 << 17
        if (this.$refs.basicTab.query.ck_007_sys_setting_3_18) params.sp3 |= 1 << 18
        if (this.$refs.basicTab.query.ck_007_sys_setting_3_19) params.sp3 |= 1 << 19
        if (this.$refs.wechatTab.query.ck_007_sys_setting_3_20) params.sp3 |= 1 << 20
        if (this.$refs.wechatTab.query.ck_007_sys_setting_3_21) params.sp3 |= 1 << 21
        if (this.$refs.wechatTab.query.ck_007_sys_setting_3_22) params.sp3 |= 1 << 22
        if (this.$refs.wechatTab.query.ck_007_sys_setting_3_23) params.sp3 |= 1 << 23
        if (this.$refs.wechatTab.query.ck_007_sys_setting_3_27) params.sp3 |= 1 << 27
        if (this.$refs.basicTab.query.ck_007_sys_setting_3_31) params.sp3 |= 1 << 31

        // if (this.$refs.distributionTab.query.ck_007_sys_setting_sp4_0) params.sp4 |= 1
        if (this.$refs.basicTab.query.ck_007_sys_setting_sp4_1) params.sp4 |= 1 << 1
        if (this.$refs.basicTab.query.ck_007_sys_setting_sp4_2) params.sp4 |= 1 << 2
        if (this.$refs.wechatTab.query.ck_007_sys_setting_sp4_4) params.sp4 |= 1 << 4
        if (this.$refs.paywayTab.query.ck_007_sys_setting_sp4_5) params.sp4 |= 1 << 5
        if (this.$refs.paywayTab.query.ck_007_sys_setting_sp4_6) params.sp4 |= 1 << 6
        if (this.$refs.wechatTab.query.ck_007_sys_setting_sp4_7) params.sp4 |= 1 << 7
        if (this.$refs.wechatTab.query.ck_007_sys_setting_sp4_8) params.sp4 |= 1 << 8
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp4_9) params.sp4 |= 1 << 9
        if (this.$refs.wechatTab.query.ck_007_sys_setting_sp4_12) params.sp4 |= 1 << 12
        if (this.$refs.wechatTab.query.ck_007_sys_setting_sp4_13) params.sp4 |= 1 << 13
        if (this.$refs.wechatTab.query.ck_007_sys_setting_sp4_14) params.sp4 |= 1 << 14
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp4_16) params.sp4 |= 1 << 16
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp4_17) params.sp4 |= 1 << 17
        // if (this.$refs.orderTab.query.ck_007_sys_setting_sp4_20) params.sp4 |= 1 << 20
        if (this.$refs.distributionTab.query.ck_007_sys_setting_sp4_18) params.sp4 |= 1 << 18
        if (this.$refs.distributionTab.query.ck_007_sys_setting_sp4_19) params.sp4 |= 1 << 19
        if (this.$refs.distributionTab.query.ck_007_sys_setting_sp4_20) params.sp4 |= 1 << 20
        if (this.$refs.distributionTab.query.ck_007_sys_setting_sp4_23) params.sp4 |= 1 << 23
        if (this.$refs.basicTab.query.ck_007_sys_setting_sp4_21) params.sp4 |= 1 << 21
        if (this.$refs.basicTab.query.ck_007_sys_setting_sp4_22) params.sp4 |= 1 << 22
        // if (this.$refs.settlementTab.query.ck_007_sys_setting_sp4_26) params.sp4 |= 1 << 26
        if (this.$refs.paywayTab.query.ck_007_sys_setting_sp4_29) params.sp4 |= 1 << 29

        console.log(this.$refs.orderTab.query.ck_007_sys_setting_sp4_30, this.$refs.orderTab.query.ck_007_sys_setting_sp4_33)

        if (this.$refs.basicTab.query.ck_007_sys_setting_5_0) params.sp5 |= 1 << 0
        if (this.$refs.basicTab.query.ck_007_sys_setting_5_1) params.sp5 |= 1 << 1
        if (this.$refs.basicTab.query.ck_007_sys_setting_5_2) params.sp5 |= 1 << 2
        if (this.$refs.basicTab.query.ck_007_sys_setting_5_3) params.sp5 |= 1 << 3
        if (this.$refs.basicTab.query.ck_007_sys_setting_5_4) params.sp5 |= 1 << 4
        if (this.$refs.basicTab.query.ck_007_sys_setting_5_5) params.sp5 |= 1 << 5
        if (this.$refs.basicTab.query.ck_007_sys_setting_5_6) params.sp5 |= 1 << 6
        if (this.$refs.basicTab.query.ck_007_sys_setting_5_7) params.sp5 |= 1 << 7
        if (this.$refs.basicTab.query.ck_007_sys_setting_5_8) params.sp5 |= 1 << 8
        if (this.$refs.basicTab.query.ck_007_sys_setting_5_9) params.sp5 |= 1 << 9
        if (this.$refs.basicTab.query.ck_007_sys_setting_5_10) params.sp5 |= 1 << 10
        if (this.$refs.basicTab.query.ck_007_sys_setting_5_11) params.sp5 |= 1 << 11
        if (this.$refs.basicTab.query.ck_007_sys_setting_5_12) params.sp5 |= 1 << 12
        if (this.$refs.basicTab.query.ck_007_sys_setting_sp6_9) params.sp6 |= 1 << 9
        if (this.$refs.basicTab.query.ck_007_sys_setting_5_13) params.sp5 |= 1 << 13
        if (this.$refs.basicTab.query.ck_007_sys_setting_5_14) params.sp5 |= 1 << 14
        if (this.$refs.basicTab.query.ck_007_sys_setting_sp5_15) 	params.sp5 |= 1 << 15 // wjh  云呼叫
        if (this.$refs.basicTab.query.ck_007_sys_setting_sp6_9) params.sp6 |= 1 << 9

        if (this.$refs.orderTab.query.ck_007_sys_setting_sp5_16) params.sp5 |= 1 << 16
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp5_17) params.sp5 |= 1 << 17
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp5_18) params.sp5 |= 1 << 18
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp5_19) params.sp5 |= 1 << 19
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp5_20) params.sp5 |= 1 << 20
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp5_21) params.sp5 |= 1 << 21
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp5_22) params.sp5 |= 1 << 22
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp5_23) params.sp5 |= 1 << 23
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp5_24) params.sp5 |= 1 << 24
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp5_25) params.sp5 |= 1 << 25
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp6_22) params.sp6 |= 1 << 22
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp6_28) params.sp6 |= 1 << 28
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp6_29) params.sp6 |= 1 << 29
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp6_25) params.sp6 |= 1 << 25
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp6_30) params.sp6 |= 1 << 30
        if (this.$refs.orderTab.query.ck_007_sys_setting_sp7_1) params.sp7 |= 1 << 1

        if (this.$refs.orderTab.query.ck_007_sys_setting_sp6_25) {
          if (!this.$refs.orderTab.query.orderReturnDay) {
            return this.$message.warning('请设置自动退单时间')
          }
          params.orderReturnDay = this.$refs.orderTab.query.orderReturnDay
        }
        if (this.$refs.openAccountTab.query.ck_007_sys_setting_1_5) {
          // if (!(this.$refs.openAccountTab.checkList_setting_1_5_channel2.length > 0)) {
          //   this.$message.warning('请选择所有渠道新建客户默认为未审核下生效渠道')
          //   return
          // }
          params.sp1 |= 1 << 5

          // params.relationGroupSubType = this.$refs.openAccountTab.checkList_sp6_channel2.join(',')
        }

        if (this.$refs.openAccountTab.query.ck_007_sys_setting_sp6_1) {
          if (!(this.$refs.openAccountTab.checkList_sp6_type.length > 0)) {
            this.$message.warning('请选择押金审核状态同步客户审核状态下生效类型')
            return
          }
          if (!(this.$refs.openAccountTab.checkList_sp6_channel.length > 0)) {
            this.$message.warning('请选择押金审核状态同步客户审核状态下生效渠道')
            return
          }
          params.sp6 |= 1 << 1
          params.depSyncCusSubType = this.$refs.openAccountTab.checkList_sp6_type.join(',')
          params.depSyncCusFromPlat = this.$refs.openAccountTab.checkList_sp6_channel.join(',')
        }
        if (this.$refs.openAccountTab.query.ck_007_sys_setting_sp6_2) params.sp6 |= 1 << 2
        if (this.$refs.openAccountTab.query.ck_007_sys_setting_sp6_3) {
          if (!(this.$refs.openAccountTab.checkList_sp6_type2.length > 0)) {
            this.$message.warning('请选择启用关联客户组下生效类型')
            return
          }
          params.sp6 |= 1 << 3
          params.relationGroupSubType = this.$refs.openAccountTab.checkList_sp6_type2.join(',')
        }

        if (this.$refs.openAccountTab.query.ck_007_sys_setting_sp6_10) params.sp6 |= 1 << 10
        if (this.$refs.openAccountTab.query.ck_007_sys_setting_sp6_11) params.sp6 |= 1 << 11
        if (this.$refs.openAccountTab.query.ck_007_sys_setting_sp6_16) params.sp6 |= 1 << 16
        if (this.$refs.openAccountTab.query.ck_007_sys_setting_sp6_23) params.sp6 |= 1 << 23
        if (this.$refs.openAccountTab.query.ck_007_sys_setting_sp6_24) {
          if (!(this.$refs.openAccountTab.bottleSignedEffectChannel.length > 0)) {
            this.$message.warning('请选择租瓶签署协议下生效渠道')
            return
          }
          params.sp6 |= 1 << 24
          params.bottleSignedEffectChannel = this.$refs.openAccountTab.bottleSignedEffectChannel.join(',')
        }
        if (this.$refs.basicTab.query.ck_007_sys_setting_sp6_12) params.sp6 |= 1 << 12
        if (this.$refs.basicTab.query.ck_007_sys_setting_sp6_15) params.sp6 |= 1 << 15
        if (this.$refs.basicTab.query.ck_007_sys_setting_sp6_17) params.sp6 |= 1 << 17
        if (this.$refs.basicTab.query.ck_007_sys_setting_sp6_18) params.sp6 |= 1 << 18
        if (this.$refs.basicTab.query.ck_007_sys_setting_sp6_19) params.sp6 |= 1 << 19
        if (this.$refs.basicTab.query.ck_007_sys_setting_sp6_20) params.sp6 |= 1 << 20

        if (this.$refs.basicTab.query.ck_007_sys_setting_sp6_26) {
          if (!(this.$refs.basicTab.query.checkTypes_sp6_26.length > 0)) {
            this.$message.warning('请选择启动安检隐患告知单状态下生效安检类型')
            return
          }
          if (!(this.$refs.basicTab.query.warnLevels_sp6_26.length > 0)) {
            this.$message.warning('请选择启动安检隐患告知单状态下生效隐患等级')
            return
          }
          params.sp6 |= 1 << 26
          params.checkTypes = this.$refs.basicTab.query.checkTypes_sp6_26.join(',')
          params.warnLevels = this.$refs.basicTab.query.warnLevels_sp6_26.join(',')
        }

        const hour = this.$refs.settlementTab.query.hour

        const time = `1970-01-01 ${hour}:00`

        if (this.$refs.settlementTab.query.ck_007_sys_setting_time1) params.time1 = moment(time).format()
        if (this.$refs.settlementTab.query.ck_007_sys_setting_time2) params.time2 = moment(time).format()
        if (this.$refs.settlementTab.query.handTime) {
          const handTime = `1970-01-01 ${this.$refs.settlementTab.query.handTime}:00`
          params.handTime = moment(handTime).format()
        }
        if (this.$refs.settlementTab.query.accountTime) {
          const accountTime = `1970-01-01 ${this.$refs.settlementTab.query.accountTime}:00`
          params.accountTime = moment(accountTime).format()
        }

        const info = this.$refs.wechatTab.query.validateContent
        if (info === 1) {
          // 仅校验手机号
          params.sp3 |= 1 << 28
        }
        if (info === 2) {
          // 校验手机号和客户编号
          params.sp3 |= 1 << 28
          params.sp3 |= 1 << 29
        }
        if (info === 3) {
          // 校验手机号和客户名称
          params.sp3 |= 1 << 28
          params.sp3 |= 1 << 30
        }
        if (info === 4) {
          // 校验手机号，客户名称，客户编号
          params.sp3 |= 1 << 28
          params.sp3 |= 1 << 29
          params.sp3 |= 1 << 30
        }
        const info1 = this.$refs.basicTab.chipSupport
        if (info1 === 2) {
          // 选中华申
          params.sp4 |= 1 << 22
        }
        if (info1 === 3) {
          // 选中祥康
          params.sp4 |= 1 << 23
        }

        // -----------------预约时间-----------------------------
        const formSaveDay = this.$refs.appointmentTime.formSave
        const formSaveDay2 = this.$refs.appointmentTime.formSave2
        const formSave = this.$refs.preciseTime.formSave
        console.log(formSaveDay, formSave, '-----------')

        let query = {}
        let queryDay1 = {}
        let queryDay2 = {}
        if (formSaveDay && formSaveDay.timeGrade && formSaveDay.timeGrade.length > 0) {
          queryDay1 = { // 日达
            params: formSaveDay.timeGrade.map((item, index) => ({
              startTime: dayjs(item.start).format('HH:mm') + ':00',
              endTime: dayjs(item.end).format('HH:mm') + ':00',
              deadlineTime: dayjs(item.delivery).format('HH:mm') + ':00'
            })),
            dayType: formSaveDay.dayType
          }
        }
        if (formSaveDay2 && formSaveDay2.timeGrade && formSaveDay2.timeGrade.length > 0) {
          queryDay2 = { // 日达
            params: formSaveDay2.timeGrade.map((item, index) => ({
              startTime: dayjs(item.start).format('HH:mm') + ':00',
              endTime: dayjs(item.end).format('HH:mm') + ':00',
              deadlineTime: dayjs(item.delivery).format('HH:mm') + ':00'
            })),
            dayType: formSaveDay2.dayType
          }
        }

        if (formSave && formSave.timeGrade && formSave.timeGrade.length > 0) {
          query = {
            params: formSave.timeGrade.map((item, index) => ({
              startTime: item.start + ':00',
              endTime: item.end + ':00',
              showIndex: index + 1
            })),
            type: formSave.type
          }
        }
        // 预约时间修改次数
        params.orderAppointCount = this.$refs.orderTab.query.orderAppointCount || 99
        // ---------------------------------------------------

        console.log(query, queryDay2, queryDay1)

        this.$confirm('是否确定保存，一旦保存配置，立马生效', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async() => {
          if (query.type) appointTimeSettingSave(query)// 精准时段
          if (queryDay1.dayType) appointTimeSettingDaySave(queryDay1) // 日达大车
          if (queryDay2.dayType) appointTimeSettingDaySave(queryDay2)// 日达
          await querySaveProcessConfig(params)
          await store.dispatch('user/getCorpSettingData')
          this.$notify({
            title: '提示',
            message: '保存成功',
            type: 'success',
            duration: 2000
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          })
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
.process-config-tabs {
  height: 100%;
  .el-tabs {
    height: calc(100% - 100px);
    overflow: auto;
  }
  .btn {
    margin-top: 20px;
    text-align: center;
  }
}
</style>
